package com.zm.demo.core.nio;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;

/**
 * @author zoum
 * @create 2019/9/16 17:26
 */
public class DatagramChannelSendT {


    public static void main(String[] args)throws Exception {

        try(DatagramChannel channel = DatagramChannel.open()){
            channel.socket().bind(new InetSocketAddress(9912));
            ByteBuffer buf = ByteBuffer.allocate(48);
            buf.put("this is first msg.".getBytes());
            buf.flip();
            channel.send(buf, new InetSocketAddress("127.0.0.1", 9911));
        }

    }
}
